package com.vogue.api.controller;

import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.ShearCaptcha;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 页面映射
 */
@Controller
public class PageController {

    @GetMapping("captcha")
    @ResponseBody
    public String getCaptcha(){
        ShearCaptcha captcha = CaptchaUtil.createShearCaptcha(111, 36);
        // 验证码对应的字符串
        String code = captcha.getCode();
        System.out.println("真实验证码是："+code);
        // 返回图片流
        return "data:image/png;base64,"+ captcha.getImageBase64();
    }
    /**
     * 登录
     * @return
     */
    @GetMapping("/login.html")
    public String login()
    {
        return "login";
    }

    /**
     * 登录
     * @return
     */
    @GetMapping("/jsencrypt.html")
    public String jsencrypt()
    {
        return "jsencrypt";
    }
    /**
     * 模块功能页面
     * @param model
     * @param url
     * @return
     */
    @GetMapping("/{model}/{url}.html")
    public String Page(@PathVariable String model, @PathVariable String url)
    {
        return model+"/"+url;
    }
}
